package Model;

import java.util.ArrayList;

public class SalesOrder {
    private int id;
    private String date;
    private double totalPrice;
    private String deliveryStatus;
    private String deliveryDate;
    private int customer;
    private ArrayList<SalesOrderProduct> salesOrderProductList;


    public SalesOrder(int id, String date, String deliveryStatus, String deliveryDate) {
        this.id = id;
        this.date = date;
        this.deliveryStatus = deliveryStatus;
        this.deliveryDate = deliveryDate;
    }

    public SalesOrder(int id, String date, double totalPrice, String deliveryStatus, String deliveryDate, int customer, ArrayList<SalesOrderProduct> salesOrderProductList) {
        this.id = id;
        this.date = date;
        this.totalPrice = totalPrice;
        this.deliveryStatus = deliveryStatus;
        this.deliveryDate = deliveryDate;
        this.customer = customer;
        this.salesOrderProductList = salesOrderProductList;
    }

    public SalesOrder(){
        salesOrderProductList = new ArrayList<SalesOrderProduct>();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getDate() {
        return date;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public void setDate(String date) {
        this.date = date;

    }

    public String getDeliveryStatus() {
        return deliveryStatus;
    }

    public void setDeliveryStatus(String deliveryStatus) {
        this.deliveryStatus = deliveryStatus;
    }

    public String getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(String deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    public int getCustomer() {
        return customer;
    }

    public void setCustomer(int customer) {
        this.customer = customer;
    }

    public ArrayList<SalesOrderProduct> getSalesOrderProductList() {
        return salesOrderProductList;
    }

    public void setSalesOrderProductList(ArrayList<SalesOrderProduct> salesOrderProductList) {
        this.salesOrderProductList = salesOrderProductList;
    }

    public void addProductToSalesOrder(SalesOrderProduct so) {
        salesOrderProductList.add(so);
    }

    public void addCustomerToSalesOrder(Customer c) {
        customer = c.getId();
    }

    public double getTotalPrice(){
        double totalPrice = 0;

        for(SalesOrderProduct dom : salesOrderProductList){
            totalPrice = totalPrice + dom.getProduct().getSalesPrice() * dom.getAmount();
        }
        return totalPrice;
    }
}
